#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct Review{
        string title;
        int rating;
};

bool FillReview(Review &rr);
void ShowReview(const Review &rr);

int main()
{
        vector<Review> books;
        Review temp;

        while(FillReview(temp))
                books.push_back(temp);
 
        int num=books.size();
	if(num>0)
	{
		cout<<"thank you ,you entered the following:\n"<<"rating\tBook\n";
		for(int i=0;i<num;++i)
			ShowReview(books[i]);
		cout<<"reprising:\n"<<"rating\tBook\n";
		vector<Review>::iterator pr;
		for(pr=books.begin();pr!=books.end();pr++)
		{
			ShowReview(*pr);
		}
		vector <Review> oldlist(books);
		if(num>3)
		{
			books.erase(books.begin()+1,books.begin()+3);
			cout<<"after erasure:\n";
			for(pr=books.begin();pr!=books.end();pr++)
				ShowReview(*pr);
			books.insert(books.begin(),oldlist.begin()+1,oldlist.begin()+2);
			cout<<"after insertion:\n";
			for(pr=books.begin();pr!=books.end();pr++)
				ShowReview(*pr);
		}
		books.swap(oldlist);
		cout<<"Swaping oldlist with books:\n";
		for(pr=books.begin();pr!=books.end();pr++)
			ShowReview(*pr);
	}
	else
		cout<<"nothing entered,nothing gained.\n";
	return 0;
}
bool FillReview(Review &rr)
{
	cout<<"enter book title(quit to quit):";
	getline(cin,rr.title);
	if(rr.title=="quit")
		return false;
	cout<<"enter book rating:";
	cin>>rr.rating;
	if(!cin)
		return false;
	cin.get();
	return true;
}

void ShowReview(const Review &rr)
{
	cout<<rr.rating<<"\t"<<rr.title<<endl;
}

